module.exports = (app) => {
  const mongoose = app.mongoose;
  mongoose.pluralize(null);
  const Schema = mongoose.Schema;
  // 商品的组合属性详情
  // 通过goods_id关联对应商品（杨枝甘露），通过多个子属性id关联到具体型号（七分糖常温），查询到价格和库存
  const AttrdetailSchema = new Schema(
    {
      goodsId: {
        type: mongoose.Types.ObjectId,
        ref: "Goods",
        required: true,
      },
      price: {
        type: Number,
        required: true,
      },
      stock: {
        type: Number,
        required: true,
      },
      specs: {
        type: [String],
        required: true,
      },
      sid: {
        type: [String],
        required: true,
      },
    },
    { versionKey: false, timestamps: true }
  );
  return mongoose.model("Attrdetail", AttrdetailSchema);
};
